<div id="content_header">
  <h3>Scheduling a new Placement Test</h3>
</div>
<!-- FORM SEARCH STUDENTS -->
<div class="row" ng-hide="ptNew.Student.Id">
  <div class="col-md-6">
    <form role="form" ng-submit="searchStudent()">
      <div class="form-group">
        <div class="input-group">
          <input type="text" class="form-control" id="" placeholder="Input Student ID or Student Name and press enter to search" ng-model="searchText">
          <span class="input-group-btn">
            <button type="submit" class="btn btn-primary"><i class="simple-icon-magnifier"></i> Search</button>
          </span>
        </div>
      </div>
    </form>
    
  </div>
</div>

<!-- RESULTS BY SEARCHING STUDENT NAME / SID  -->
<div class="row" ng-if="students.length > 0" ng-hide="ptNew.Student.Id">
  <div class="col-md-12">
    <table class="table table-hover">
      <thead>
        <tr>
          <th>Name</th>
          <th>SID</th>
          <th>Latest PT</th>
          <th>Latest Course Taken</th>
        </tr>
      </thead>
      <tbody>
        <tr dir-paginate="student in students | itemsPerPage: pagesize" total-items="totalItems">
          <td>
            <span class="dropdown">
              <a href class="dropdown-toggle">
                {{ student.FullName }}
              </a>
              <ul class="dropdown-menu">
                <!-- <li role="presentation" class="dropdown-header">Action</li> -->
                <li ng-if="!student.PlacementTest"><a href ng-click="selectStudent(student.Id)">Register to PT</a></li>
                <li ng-if="!student.Enrollment"><a href ui-sref="sr.new({ id:student.Id })">Register to Course</a></li>
                <li ng-if="!student.PlacementTest"><a href ng-really-message="Are you sure?" ng-really-click="delete(placement_tests, student.PlacementTest.Id, {withCollection: false})">Delete Placement Test</a></li>
                <li ng-if="student.PlacementTest"><a href ui-sref="pt.edit({ id:student.PlacementTest.Id })">Edit Placement Test</a></li>
              </ul>
            </span>
          </td>
          <td ng-bind-html="student.SID | makeBold:searchKey"></td>
          <td>
            <span ng-if="!student.LatestPlacementTest"><a href ng-click="selectStudent(student.Id)">No Valid PT, Register to PT</a></span>
            <span ng-if="student.LatestPlacementTest">{{ student.LatestPlacementTest.DateTime  | date:'medium' }}</span>
            <!-- <span ng-if="!student.PlacementTest"></span> -->
          </td>
          <td>{{ (student.LatestEnrollments) ? CourseCompletionStatus[student.LatestEnrollments.CourseCompletionStatus].Label : '-' }}</td>
        </tr>
      </tbody>
    </table>
    <dir-pagination-controls on-page-change="pageChanged(newPageNumber)" template-url="views/templates/dirPagination.tpl.html"></dir-pagination-controls>
    
  </div>
</div>

<!-- PT FORM INPUT -->
<div class="row">
  <div class="col-md-12 col-lg-4">
    <form ng-show="ptNew.Student.Id" name="ptForm" role="form" ng-submit="addPT()">

      <div class="form-group" ng-class="{ 'has-error': errors.Student}">
        <label class="required" for="">Student</label>
        <span class="form-control">{{ currStudent.FullName }} <small><a href="" ng-click="resetStudent()">Change Student</a></small></span>
        <error-widget field="errors.Student"></error-widget>
      </div>

      <div class="form-group" ng-class="{ 'has-error': errors.PlacementTestType}">
        <label class="required" for="">Type</label>
        <label ng-repeat="type in PlacementTestTypes"><input type="radio" ng-value="type.Id" ng-model="ptNew.PlacementTestType"> {{ type.Label }} </label>
        <error-widget field="errors.PlacementTestType"></error-widget>
      </div>

      <!-- <div class="form-group">
        <label for="class">Classroom</label>
        <select name="class" id="class" class="form-control" ng-options="class.Id as class.Name for class in classrooms" ng-model="ptNew.Classroom.Id" required>
          <option value="" ng-hide="ptNew.Classroom.Id">Please Select a Classroom</option>
        </select>
      </div> -->

      <!-- <div class="form-group" ng-class="{ 'has-error': errors.Staff}">
        <label class="required" for="Staff">Interviewer</label>
        <select name="Staff" id="Staff" class="form-control" ng-options="teacher.Id as teacher.Name for teacher in teachers" ng-model="ptNew.Staff.Id">
          <option value="">Please Select an Interviewer</option>
        </select>
        <error-widget field="errors.Staff"></error-widget>
      </div> -->

      <div class="form-group" ng-click="openDatepicker($event, 0)" ng-class="{ 'has-error': errors.DateTime}">
        <label class="required" for="">Date</label>
        <div class="input-group">
          <input type="hidden" class="form-control" datepicker-popup="{{format}}" ng-model="timepicker.timeA" is-open="datePicker.isOpen[0]" datepicker-options="dateOptions" ng-required="true" close-text="Close" ng-disabled="true" />
          <span class="form-control">{{ timepicker.timeA | date: 'dd MMMM yyyy' }}</span>
          <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
        </div>
        <error-widget field="errors.DateTime"></error-widget>
      </div>

      <div class="form-group" ng-class="{ 'has-error': errors.DateTime}">
        <label class="required" for="">Time</label>
        <timepicker ng-model="timepicker.timeA" hour-step="timepicker.hstep" minute-step="timepicker.mstep" show-meridian="timepicker.isMeridian"></timepicker>
        <error-widget field="errors.DateTime"></error-widget>
      </div>

      <button type="submit" class="btn btn-primary" >Submit</button>
    </form>
  </div>
</div>